/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.mailbox.CalendarItem;
/*    */ import com.zimbra.cs.mailbox.MailSender;
/*    */ import com.zimbra.cs.mailbox.MailServiceException;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.mailbox.calendar.Invite;
/*    */ import com.zimbra.cs.service.util.ItemId;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CounterCalendarItem
/*    */   extends CalendarRequest
/*    */ {
/*    */   private class InviteParser
/*    */     extends ParseMimeMessage.InviteParser
/*    */   {
/*    */     private Invite mInv;
/*    */     
/*    */     InviteParser(Invite inv)
/*    */     {
/* 41 */       this.mInv = inv;
/*    */     }
/*    */     
/*    */     public ParseMimeMessage.InviteParserResult parseInviteElement(ZimbraSoapContext lc, OperationContext octxt, Account account, Element inviteElem)
/*    */       throws ServiceException
/*    */     {
/* 47 */       return CalendarUtils.parseInviteForCounter(account, this.mInv, CounterCalendarItem.this.getItemType(), inviteElem);
/*    */     }
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 53 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 54 */     Account acct = getRequestedAccount(zsc);
/* 55 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 56 */     OperationContext octxt = getOperationContext(zsc, context);
/* 57 */     Invite oldInv = null;
/*    */     
/*    */ 
/* 60 */     String idStr = request.getAttribute("id", null);
/* 61 */     if (idStr != null) {
/* 62 */       ItemId iid = new ItemId(idStr, zsc);
/* 63 */       if (!iid.belongsTo(acct)) {
/* 64 */         return proxyRequest(request, context, iid.getAccountId());
/*    */       }
/* 66 */       CalendarItem calItem = mbox.getCalendarItemById(octxt, iid.getId());
/* 67 */       if (calItem == null) {
/* 68 */         throw MailServiceException.NO_SUCH_CALITEM(iid.toString(), "Could not find calendar item");
/*    */       }
/*    */       
/*    */ 
/* 72 */       int modSeq = (int)request.getAttributeLong("ms", 0L);
/* 73 */       int revision = (int)request.getAttributeLong("rev", 0L);
/* 74 */       if ((modSeq != 0) && (revision != 0) && ((modSeq < calItem.getModifiedSequence()) || (revision < calItem.getSavedSequence())))
/*    */       {
/* 76 */         throw MailServiceException.INVITE_OUT_OF_DATE(iid.toString());
/*    */       }
/* 78 */       int compNum = (int)request.getAttributeLong("comp", 0L);
/* 79 */       if (compNum != 0) {
/* 80 */         oldInv = calItem.getInvite(iid.getSubpartId(), compNum);
/* 81 */         if (oldInv == null) {
/* 82 */           throw MailServiceException.INVITE_OUT_OF_DATE(iid.toString());
/*    */         }
/*    */       }
/*    */     }
/* 86 */     Element msgElem = request.getElement("m");
/* 87 */     InviteParser parser = new InviteParser(oldInv);
/* 88 */     CalendarRequest.CalSendData dat = handleMsgElement(zsc, octxt, msgElem, acct, mbox, parser);
/*    */     
/* 90 */     MailSender mailSender = mbox.getMailSender();
/* 91 */     mailSender.sendMimeMessage(octxt, mbox, dat.mMm);
/* 92 */     Element response = getResponseElement(zsc);
/* 93 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/CounterCalendarItem.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */